package migrations

import (
	"database/sql"

	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/migrate"

	"gorm.io/gorm"
)

// http://sql2struct.atotoa.com/
func init() {

	// 开通区域表
	type Region struct {
		models.BaseModel

		Name string `gorm:"type:varchar(255);comment:区域名称;" db:"name" json:"name" form:"name"`

		models.CommonTimestampsField
	}

	up := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.AutoMigrate(&Region{})
	}

	down := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.DropTable(&Region{})
	}

	migrate.Add("2023_07_19_104707_add_regions_table", up, down)
}
